package com.cxhc.app.api;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.cxhc.system.domain.app.CmHandlingInfo;
import com.cxhc.system.service.app.ICmHandlingInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cxhc.common.core.controller.BaseController;
import com.cxhc.common.core.domain.AjaxResult;
import com.cxhc.common.utils.poi.ExcelUtil;
import com.cxhc.common.core.page.TableDataInfo;

/**
 * 警情举报Controller
 * 
 * @author Dhq
 * @date 2024-11-14
 */
@RestController
@RequestMapping("/api/handling")
public class CmHandlingInfoController extends BaseController
{
    @Autowired
    private ICmHandlingInfoService cmHandlingInfoService;

    /**
     * 查询警情举报列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CmHandlingInfo cmHandlingInfo)
    {
        startPage();
        List<CmHandlingInfo> list = cmHandlingInfoService.selectCmHandlingInfoList(cmHandlingInfo);
        return getDataTable(list);
    }

    /**
     * 导出警情举报列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmHandlingInfo cmHandlingInfo)
    {
        List<CmHandlingInfo> list = cmHandlingInfoService.selectCmHandlingInfoList(cmHandlingInfo);
        ExcelUtil<CmHandlingInfo> util = new ExcelUtil<CmHandlingInfo>(CmHandlingInfo.class);
        util.exportExcel(response, list, "警情举报数据");
    }

    /**
     * 获取警情举报详细信息
     */
    @GetMapping(value = "/detail/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cmHandlingInfoService.selectCmHandlingInfoById(id));
    }

    /**
     * 新增警情举报
     */
    @PostMapping("/insert")
    public AjaxResult add(@RequestBody CmHandlingInfo cmHandlingInfo)
    {
        return toAjax(cmHandlingInfoService.insertCmHandlingInfo(cmHandlingInfo));
    }

    /**
     * 修改警情举报
     */
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody CmHandlingInfo cmHandlingInfo)
    {
        return toAjax(cmHandlingInfoService.updateCmHandlingInfo(cmHandlingInfo));
    }

    /**
     * 删除警情举报
     */
    @GetMapping(value = "/delete/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(cmHandlingInfoService.deleteCmHandlingInfoById(id));
    }
}
